#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    vector<vector<int>> generate(int numRows) {
        //g[i][n]=g[i-1][n-1]+g[i-1][n]
        vector<vector<int>> result(numRows);
        for (int i = 0; i < numRows; i++) {

            result[i].resize(i + 1);

            result[i][0] = 1;
            result[i][i] = 1;

            if (numRows > 2) {
                for (int j = 1; j < i; j++)
                    result[i][j] = result[i - 1][j - 1] + result[i - 1][j];
            }

        }
        return result;
    }
};

